//
//  HomeView.swift
//  iPad_QQ
//
//  Created by 李善武 on 16/4/29.
//  Copyright © 2016年 李善武. All rights reserved.
//

import UIKit

class Dock: UIView {
    // 懒加载menu
    private lazy var menu :BottomMenu = {
       let menu = BottomMenu()
        self.addSubview(menu)
        menu.backgroundColor = UIColor.blueColor()
        menu.autoresizingMask = .FlexibleTopMargin
        
        return menu
    }()
    
    // 只读
    var getMenu : BottomMenu{
        get{
           return menu
        }
    }
    // 懒加载tabBar
    private lazy var tabBar : TabBar = {
       let tabBar = TabBar()
       self.addSubview(tabBar)
       tabBar.backgroundColor = UIColor.orangeColor()
       tabBar.autoresizingMask = .FlexibleTopMargin
        
       return tabBar
    }()
    
    // 只读
    var getTb : TabBar{
        get{
          return tabBar
        }
    }
    // 懒加载IconButton
    private lazy var ib : IconButton = {
       let ib = IconButton()
       self.addSubview(ib)
       ib.backgroundColor = UIColor.blueColor()
        
       return ib
    }()
    
    // 只读
    var getIb : IconButton {
        get{
           return ib
        }
    }
    
    
    func rotateToLandscape(isLandscape : Bool){
        frame.size.width = isLandscape ? landscapeWidth :PortraitWidth
        menu.rotateToLandscape(isLandscape)
        
        // 将屏幕方向信息传入TabBar
        tabBar.rotateToLandscape(isLandscape)
        tabBar.frame.origin.y = self.frame.height - menu.frame.height - tabBar.frame.height
        
        // 将屏幕方向信息传入IconButton
        ib.rotateToLandscape(isLandscape)
    }

}
